<%= render 'admin/nav' %>
<h1>Popular packages without repo links</h1>
<%= page_entries_info @projects %>
<div class="row">
  <div class="col-md-8">
    <% @projects.each do |project| %>
      <div class="row">
        <div class="col-md-8">
          <%= render object: project, partial: 'projects/project' %>
        </div>
        <div class="col-md-4">
          <% if project.description.present? %>
            <%= link_to "Google", "https://www.google.com/search?q="+URI.escape('site:github.com "' + project.description.to_s + '"'), class: 'btn btn-success', target: :blank %>
          <% end %>
          <%= link_to 'Edit in Admin', admin_project_path(project.id), class: 'btn btn-primary' %>
        </div>
      </div>
    <% end %>

    <%= will_paginate @projects, page_links: false %>
  </div>
  <div class="col-md-4">
    <h3>
      <strong>
        Filter by platform
      </strong>
    </h3>
    <div class="facets">
      <ul class='filter'>
        <% @platforms.each do |platform| %>
          <li class='<%= 'active' if platform.downcase == params[:platform].try(:downcase) %>'>
            <% if platform.downcase == params[:platform].try(:downcase) %>
              <%= link_to platform, url_for(params.slice(:platform).merge(platform: nil).permit!) %>
            <% else %>
              <%= link_to platform, url_for(params.slice(:platform).merge(platform: platform).permit!) %>
            <% end %>
          </li>
        <% end %>
      </ul>
    </div>
  </div>
</div>
